package hw;

import util.Util;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Find extends JPanel implements ActionListener {
    private Atm atm;
    private Icon offImg = Util.getIcon("/buttonOff.jpg");
    private JButton  offBtn = new JButton(offImg);
    private JLabel userbalance = new JLabel( );
    public Find(Atm atm){
        this.atm = atm;
        offBtn.setBounds(930,200,140,50);
        userbalance.setBounds(400,200,240,50);
        userbalance.setFont(new java.awt.Font("宋体" ,1, 25));
        this.add(userbalance);
        this.add(offBtn);
        offBtn.addActionListener(this);
        this.setLayout(null);
        this.setOpaque(false);

    }
    public void setValue(){
        userbalance.setText("当前账户余额"+atm.getUser().getBalance()+"元");
    }


    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource()==offBtn){
            System.out.println("11");
            atm.switchPanel("menu");
        }

    }
}
